<?php

namespace app\api\model\house;

use think\Model;


class HouseOrderComplainReply extends Model
{





    // 表名
    protected $name = 'house_order_complain_reply';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];





    public static function add($complain_id,$user_id,$identity,$content,$images,$is_solve=0)
    {
        $data = [
            'complain_id'=>$complain_id,
            'user_id'=>$user_id,
            'identity'=>$identity,
            'content'=>$content,
            'images'=>$images,
            'is_solve'=>$is_solve
        ];

        $model = new HouseOrderComplainReply();
        if ($identity=='user'&&$is_solve==1){
            HouseOrderComplain::where([ 'complain_id'=>$complain_id])->update(['status'=>1]);
        }
        return $model->save($data);
    }






}
